package cn.zb.record;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;

/**
 * Created by Yang on 2015/3/10.
 */
public class Record extends Model<Record> {

    public static final Record me = new Record();

    public Page<Record> page(Integer pageNo, Integer pageSize, Integer authorId) {
        return paginate(pageNo, pageSize, "select zr.*, zu.nickname",
                "from zb_record zr left join zb_user zu on zr.author_id = zu.id " +
                        "where zr.author_id = ? order by inTime desc", authorId);
    }

    public String totalPrice(Integer authorId) {
        String sql = "SELECT FORMAT(SUM(price), 2) FROM zb_record WHERE author_id = ?";
        return Db.queryStr(sql, authorId);
    }
}
